package com.zsk.shop.enums;


import com.zsk.shop.common.enums.EnumType;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Administrator
 */

public enum EnumBannerType {
    NULL("无点击效果", 0),
    LINK_OTHER("其他连接（\"如：http://www.baidu.com\"）", 1),
    LINK_WX_MINI_GOODS("跳转商品 tip为商品编号", 4),
    LINK_BONUS_JACKPOT("跳转抽奖活动页", 5),
    ;

    String name;
    Integer code;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    EnumBannerType(String name, Integer code) {
        this.name = name;
        this.code = code;
    }

    public static List<EnumType> getList() {
        List<EnumType> result = new ArrayList<>();
        EnumBannerType[] enums = EnumBannerType.values();
        for (int i = 0; i < enums.length; i++) {
            EnumType enumType = new EnumType();
            enumType.setCode(enums[i].getCode());
            enumType.setName(enums[i].getName());
            result.add(enumType);
        }
        return result;
    }

    public static String getNameByCode(Integer code) {
        EnumBannerType[] enums = EnumBannerType.values();
        for (int i = 0; i < enums.length; i++) {
            if (enums[i].getCode().equals(code)) {
                return enums[i].getName();
            }
        }
        return "";
    }
}
